import { Color } from '@mui/material'
import { AdvisorTypeEnum, SalaryStatusEnum, ServiceStatusEnum, ServiceTypeEnum, ShiftStatusEnum } from './enum'
import { ReactNode } from 'react'
import { TablerIconsProps } from '@tabler/icons-react'

export interface ShiftItem {
  id: number
  shift_id: string
  start_delta: number
  end_delta: number
}
export interface DatePeriod {
  start_date: string
  end_date: string
}

export interface DailyShift {
  id: number
  shift_id: string
  date: string
  status: ShiftStatusEnum
}

export interface AdvisorShiftItem {
  advisor_id: string
  name: string
  email: string
  grade: string
  star_ids?: string[]
  daily_shifts: DailyShift[]
}

export interface PerformanceItem {
  advisor_id: string
  name: string
  email: string
  grade: string
  base_salary: number
  is_up: number
  is_down: number
  performance: PerformanceData
  admin_score: number
  credits: number
  total_score: number
}

export interface PerformanceData {
  top_avg: number
  repurchase: number
  new_user_conversion: number
  valid_easy_msg: number
  attendance: number
  order_complete: number
  comment_avg: number
}

export interface ShiftStatusItem {
  label: string
  status: ShiftStatusEnum
  icon: ReactNode
  color: Color
}

export type StarItem = {
  star_id: string
  email: string
  services: StarServiceItem[]
  robot: {
    id: number
    robot_status: ServiceStatusEnum
  }
} & Pick<AdvisorShiftItem, 'name' | 'grade'>

export interface StarServiceItem {
  id: number
  type: ServiceTypeEnum
  status: ServiceStatusEnum
  price: number
}

export interface AdvisorItem {
  id: number
  advisor_id: string
  name: string
  email: string
  is_up: number
  is_down: number
  grade: string
  star_ids: string[]
  train: {
    training_date: string
    examine_date: string
    work_date: string
    init_grade?: string
  }
  type: AdvisorTypeEnum
}
export interface GradeItem {
  id: number
  grade: string
  credit_base: number
  credit_up: number
  performance_base: number
  performance_up: number
  next_grade: string
  last_grade: string
}

export type ButtonType = Record<
  'add' | 'edit' | 'delete',
  {
    label: string
    icon: (props: TablerIconsProps) => JSX.Element
  }
>

export interface SalaryItem {
  id: number
  name: string
  advisor_id: string
  grade: string
  basic_salary: number
  achievement_bonus: number
  performance_reward: number
  refund_risk_deposit: number
  released_deposit: number
  in_all: number
  status: SalaryStatusEnum
}
